local huantu = fk.CreateSkill {
  name = "lingling__huantu",
}

Fk:loadTranslationTable {
  ["lingling__huantu"] = "缓图",
  [":lingling__huantu"] = "当你受到伤害后，你可以摸一张牌，" ..
      "然后将一张牌置于武将牌上，称为“图”。你每有一张“图”，你的手牌上限+1。",

  ["lingling__zhudi_tu"] = "图",
  ["#lingling__huantu-push"] = "缓图：选择一张牌作为“图”置于武将牌上",
}

huantu:addEffect(fk.Damaged, {
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(huantu.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    player:drawCards(1, huantu.name)
    if not (player.dead or player:isNude()) then
      local card = room:askToCards(player, {
        min_num = 1,
        max_num = 1,
        include_equip = true,
        skill_name = huantu.name,
        cancelable = false,
        prompt = "#lingling__huantu-push",
      })
      player:addToPile("lingling__zhudi_tu", card, true, huantu.name)
    end
  end
})

huantu:addEffect("maxcards", {
  correct_func = function(self, player)
    if player:hasSkill(huantu.name) then
      return #player:getPile("lingling__zhudi_tu")
    else
      return 0
    end
  end,
})

return huantu
